print the elements of a linked list hackerrank solution in python